<%@ page import="java.util.List"%>
<%@ page import="domain.model.user.User"%>
<%@ page import="domain.model.group.Group"%>
<%@ page import="domain.model.requestInvite.RequestInvite" %>
<%@ page import="domain.model.group.mapper.GroupInputMapper" %>
<%@ page import="domain.model.user.IUser" %>  
<%@ page import="domain.model.group.IGroup" %>  

<h2> ${title} </h2>
<div>${msg}</div>
		
		<div id="queryContents">
		
		<table border="1" style="border-collapse: collapse;">
			<tr>
				<th>Name</th>
				<th>&nbsp;</th>
			</tr>
			<%
				List<Group> groups = (List<Group>)request.getAttribute("groups");
				List<User> users = (List<User>)request.getAttribute("users");
				List<Integer> invitedUsers = (List<Integer>)request.getAttribute("invitedList");
				List<Integer> requestedGroups = (List<Integer>)request.getAttribute("requestedList");
				for(Group group: groups)
				{
			%>
				
				<tr>
					<td><%=group.getName()%></td>
					<td>
					<% if( requestedGroups.contains( group.getId() )) {%>
						<i>Requested</i>
					<% }else{ %>
					<form method="POST" action="RequestInvite">
						<!--  <a href="RequestInvite?userId=<%=group.getId()%>&groupId=${groupId}&userversionForInvitation=<%=group.getVersion()%>">Invite</a> -->
						<input type="hidden" value="<%=group.getId()%>" name="groupId" />
						<input type="hidden" value="${userId}" name="userId" />
						<input type="hidden" value="<%=group.getVersion()%>"  name="groupversionForRequestInvitation"/>
						<input type="submit" value="RequestInvite"/>
					</form>
					<%} %>
					</td>
				</tr>
				
			<%
				}
			%>
		</table>
		
		</div> <!--closing queryContents -->
